/*
 * Copyright 2007-2008 by Matthias Buch-Kromann <mbk.isv@cbs.dk>.
 * 
 * This file is part of the Open-source Dependency Toolkit (OSDT),
 * see http://code.google.com/p/open-source-dependency-toolkit. 
 * 
 * The OSDT is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published
 * by the Free Software Foundation, either version 3 of the License,
 * or (at your option) any later version.
 *
 * The OSDT is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with the OSDT in the file COPYING and COPYING.LESSER. If not, see
 * http://www.gnu.org/licenses.
 */


package org.osdtsystem.graphs;

import org.osdtsystem.functions.Function;
import org.osdtsystem.values.Layer;
import java.util.List;
import org.osdtsystem.exceptions.InvalidFunctionException;
import org.osdtsystem.functions.LocalFunction;
import org.osdtsystem.functions.SingletonFunction;
import org.osdtsystem.values.Location;

/**
 * The public graph interface for all methods related to the setup and
 * handling of graph functions. 
 * @author Matthias Buch-Kromann <mbk.isv@cbs.dk>
 */
public interface GraphFunctionInterface {
    // Layer functions
    public void clearLayerFunctions(Layer layer);

    /**
     * Add a node function to the given layer. By a node function, we mean
     * a function which is evaluated on all the nodes in the layer.
     * @param layer the layer
     * @param name the unique name of the function
     * @param function the node function
     * @throws InvalidFunctionException 
     */
    public void addNodeFunction(Layer layer, String name, Function function)
            throws InvalidFunctionException;
    
    /**
     * Add an edge function to the given layer. By an edge function, we mean
     * a function which is evaluated on all the edges in the layer.
     * @param layer the layer
     * @param name the unique name of the function
     * @param function the edge function
     * @throws InvalidFunctionException 
     */
    public void addEdgeFunction(Layer layer, String name, Function function)
            throws InvalidFunctionException;

    public void removeNodeFunction(Layer layer, Function f);
    public void removeEdgeFunction(Layer layer, Function f);
    public Function lookupFunction(String uniqueName);
    public List<Function> nodeFunctions(Layer layer);
    public List<Function> edgeFunctions(Layer layer);

    // Function evaluation
    public Object functionValue(Location location, String function);
    public Object functionValue(Location location, String function, GraphAccessor accessor);
    public Object cachedFunctionValue(LocalFunction<?,Function<?>> localFunction);
    public void update();
}
